package com.ykt.converter;

import com.ykt.common.constant.ParamNames;
import com.ykt.common.utils.UB;
import com.ykt.model.Shop;
import com.ykt.vo.ShopVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author long.hua
 * @version 1.0.0
 * @since 2016-05-27 07:51
 */
public class ShopConverter extends BaseConverter {


    public static ShopVo convert(Shop model){
        if(model == null){
            return null;
        }

        ShopVo vo = new ShopVo();
        BaseConverter.convert(vo, model);

        vo.setMarketId(UB.i(model.get(Shop.market_id), -1));// 市场ID
        vo.setMerchantId(UB.i(model.get(Shop.merchant_id)));// 商户ID
        vo.setShopId(model.getId());
        vo.setShopName(model.getName());
        vo.setShopLogo(model.getStr(Shop.logo)); // 商铺店招图片
        vo.setShopSummary(model.getStr(Shop.summary));
        vo.setCollected((UB.i(model.get(ParamNames.collected))));
        vo.setPhone(model.getStr(Shop.phone)); // 商户电话，非商铺的电话
        vo.setMerchantPhone(model.getStr(ParamNames.merchantPhone)); // 商户电话，非商铺的电话
        vo.setMerchantHead(model.getStr(ParamNames.merchantHead));
        vo.setMerchantName(model.getStr(ParamNames.merchantName));

        return vo;
    }

    public static List<ShopVo> convert(List<Shop> models){
        List<ShopVo> vos = new ArrayList<>();
        if(models == null){
            return vos;
        }

        for (Shop model : models) {
            vos.add(convert(model));
        }
        return vos;
    }

}
